PickupItemCommand.cs 1010 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using KairoEngine.Core;
  5. using KairoEngine.Inventory;
  6. namespace KairoEngine.CharacterSystem
  7. {
  8. public class PickupItemCommand : ICommand
  9. {
  10. CharacterController character;
  11. WorldItem worldItem;
  12. ItemContainer itemContainer;
  13. public PickupItemCommand(CharacterController character, WorldItem worldItem, ItemContainer itemContainer = null)
  14. {
  15. this.character = character;
  16. this.worldItem = worldItem;
  17. this.itemContainer = itemContainer;
  18. }
  19. public void Execute()
  20. {
  21. CharacterPickupItemAction action = new CharacterPickupItemAction(character, worldItem, itemContainer);
  22. ActionController actionController = character.GetComponent<ActionController>();
  23. if(actionController.HasAction(action) == false)
  24. {
  25. actionController.AddAction(action);
  26. }
  27. }
  28. }
  29. }