Пример #1
0
 public Character(string name, RaceType race, GenderType gender, uint age,
                  uint maxHp, uint hp, uint xp = 0, bool isTalkable = true, bool isMovable = true)
 {
     this.Name       = name;
     this.Id         = nextId++;
     this.IsTalkable = isTalkable;
     this.IsMovable  = isMovable;
     this.Race       = race;
     this.Age        = age;
     this.MaxHp      = maxHp;
     this.Hp         = hp;
     this.Xp         = xp;
     this.Gender     = gender;
     this.Inventory  = new Inventory.Inventory(this);
     this.Condition  = ConditionType.healthy;
     conditionLocker = new object();
 }
Пример #2
0
        public MainWindowPresenter()
        {
            _repo = new ZoneRepo();

            _inventory          = new Inventory.Inventory(10);
            _inventoryPresenter = new InventoryPresenter(_inventory);

            _viewmodel = new MainWindowViewModel()
            {
                OpenItemsListCommand = new DelegateCommand(OpenItemsListAction)
            };

            _view = new MainWindowView()
            {
                DataContext = _viewmodel,
                Inventory   = { Content = _inventoryPresenter.ViewContent }
            };
        }
Пример #3
0
        /// <summary>
        /// Deserializesd an <see cref="Inventory"/> from its name into a given <paramref name="inventory"/>
        /// </summary>
        /// <param name="inventory">Inventory to apply the data to</param>
        /// <param name="inventoryName">Inventory to deserialize</param>
        public static void DeSerializeInventory(Inventory.Inventory inventory, string inventoryName)
        {
            //* make the path
            string inventorySavePath = $"{savePath}/Inventorys/{inventoryName}.dat";

            //* checks that the file exists
            if (!File.Exists(inventorySavePath))
            {
                for (int i = 0; i < inventory.items.itemsInInventory.Length; i++)
                {
                    inventory.items.itemsInInventory[i] = null;
                }

                SerializeInventory(inventory, inventoryName);

                return;
            }

            inventory.SetAllItems((ItemsInInventory)LoadFile($"{inventorySavePath}"));
        }
Пример #4
0
        public Cow(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 54, 49),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowRightWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowLeftWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowUpWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowDownWalk"], 3, 16))
        {
            Inventory  = new Inventory.Inventory(cowGameScreen);
            CraftPanel = new CraftPanel(cowGameScreen);
            ListBars   = new List <StatusBar>
            {
                new HealthBar(cowGameScreen, this),
                new FoodBar(cowGameScreen, this),
                new SprintBar(cowGameScreen, this)
            };
            Delay        = 200f;
            HealthPoint  = 100;
            StarvePoint  = 100;
            CurrentWorld = world;
            Boost        = 1;
            SpeedX       = 1.5f;
            SpeedY       = 1f;
            CurrentWorld = world;

            _interactableList = new List <Entity>();
            _attackList       = new List <Entity>();

            _previousFocusInteractables = new HashSet <Entity>();
            _previousFocusAttackables   = new HashSet <Entity>();

            Body                     = BodyFactory.CreateRectangle(world, 0.54f, 0.15f, 0, new Vector2((float)DestRect.X / 100, (float)DestRect.Y / 100));
            Body.BodyType            = BodyType.Dynamic;
            Body.CollisionCategories = Category.All & ~Category.Cat10;
            Body.CollidesWith        = Category.All & ~Category.Cat10;

            CurrentAnim       = LeftWalk;
            Body.BodyTypeName = "cow";

            CowGameScreen.WordlsList.ForEach(worldInList => worldInList.ContactManager.Nearby += NearbyCow);
        }
Пример #5
0
 public Stash(ref DrawEnvironment.Field field, Inventory.Inventory inventory, string name) : base(ref field, inventory, Color.CadetBlue)
 {
     this.name = name;
 }
Пример #6
0
 /// <summary>
 /// Tells the rest of the game how to interact with this item
 /// </summary>
 /// <param name="playerInventory"></param>
 public override void InteractWithItem(Inventory.Inventory playerInventory)
 {
     OpenItemInvnetory(playerInventory);
 }
Пример #7
0
 public override void UseItem(ItemData itemData, uint inventoryIndex, Inventory.Inventory inventory)
 {
     base.UseItem(itemData, inventoryIndex, inventory);
     // place grid
     PlayerManager.Instance.SetBuildMode(true, BuildableStructure.Id, this, inventoryIndex, inventory);
 }
Пример #8
0
 private void OnEnable()
 {
     PlayerInput.Instance.HotkeyPressed += Handle_HotkeyPressed;
     _inventory = FindObjectOfType <Inventory.Inventory>();
     _slots     = GetComponentsInChildren <Slot>();
 }
Пример #9
0
 public virtual void UseItem(ItemData itemData, uint inventoryIndex, Inventory.Inventory inventory)
 {
     Debug.Log("Item.cs Use");
 }
Пример #10
0
 public void setInventory(Inventory.Inventory i)
 {
     this.inventory = i;
 }
Пример #11
0
        public Dungeon.Model model; // protected

        public Creature(ref DrawEnvironment.Field field, Inventory.Inventory inventory, Color color, int hp, string name, Dungeon.Model m) : base(ref field, inventory, color)
        {
            this.hp    = hp;
            this.name  = name;
            this.model = m;
        }
Пример #12
0
 public void UseItemLocal(Inventory.Inventory currentInventory, uint currentInventoryIndex)
 {
     currentInventory.LocalUseItem(currentInventoryIndex);
 }
Пример #13
0
 public void DropInventorySlot(Inventory.Inventory currentInventory, uint currentInventoryIndex)
 {
     Inventory.CmdDropItem(currentInventory.netId, currentInventoryIndex);
 }
Пример #14
0
 public void MoveInventorySlotsExternal(Inventory.Inventory currentInventory, uint currentInventoryIndex, uint targetInventoryIndex, uint targetInventoryNetId)
 {
     Inventory.CmdMoveItemExternal(currentInventoryIndex, targetInventoryIndex, currentInventory.netId, targetInventoryNetId);
 }
Пример #15
0
 public void MoveInventorySlotsInternal(Inventory.Inventory currentInventory, uint currentInventoryIndex, uint targetInventoryIndex)
 {
     currentInventory.CmdMoveItemInternal(currentInventoryIndex, targetInventoryIndex);
 }
Пример #16
0
 public virtual void Awake()
 {
     EntityTransform = transform;
     NetworkIdentity = GetComponent <NetworkIdentity>();
     Inventory       = GetComponent <Inventory.Inventory>();
 }
Пример #17
0
 private void Start()
 {
     _inventory = Instance;
     _anim      = GetComponent <Animator>();
 }
Пример #18
0
 /// <summary>
 /// Toggles the <see cref="ApiaryInventory"/> for the block
 /// </summary>
 /// <param name="inv"></param>
 /// <returns></returns>
 public override bool InteractWithBlock(Inventory.Inventory inv)
 {
     myGameobject.GetComponent <ApiaryInventory>().myblock = this;
     myGameobject.GetComponent <ApiaryInventory>().ToggleInventory(inv);
     return(true);
 }
Пример #19
0
 public Interactable(ref DrawEnvironment.Field field, Inventory.Inventory inventory, Color color)
 {
     this.position  = field;
     this.inventory = inventory;
     this.color     = color;
 }
Пример #20
0
 public void FinishedUseItem(Inventory.Inventory currentInventory, uint currentInventoryIndex)
 {
     Inventory.CmdFinishedUseItem(currentInventory.netId, currentInventoryIndex);
 }
Пример #21
0
 private void InventoryClosed(Inventory.Inventory inv)
 {
     DecreaseAllCounters();
 }
Пример #22
0
 public void FinishedUseBuildableItem(Inventory.Inventory currentInventory, uint currentInventoryIndex)
 {
     Inventory.CmdFinishedUseBuildableItem(currentInventory.netId, currentInventoryIndex, PlayerManager.Instance.BuildCursor.position);
 }
Пример #23
0
 public virtual void InteractWithItem(Inventory.Inventory playerInventory)
 {
     return;
 }
Пример #24
0
 public void SetInventory(Inventory.Inventory invetory)
 {
     _invetory = invetory;
 }
 private void Start()
 {
     inv     = GameObject.Find("Inventory").GetComponent <Inventory.Inventory>();
     tooltip = inv.GetComponent <Tooltip>();
 }
Пример #26
0
 public void SetBuildMode(bool active, uint id, ItemBuildable item, uint inventoryIndex, Inventory.Inventory inventory)
 {
     BuildMode            = active;
     CurrentBuildableItem = item;
     GameManager.StructureCursorDictionary.TryGetValue(id, out var structureCursor);
     structureCursor.InventoryIndex = inventoryIndex;
     structureCursor.Inventory      = inventory;
     BuildStructure = structureCursor;
 }
Пример #27
0
 public SearchableDetector(Inventory.Inventory inventory)
 {
     this.inventory = inventory;
 }
Пример #28
0
 public override void Awake()
 {
     base.Awake();
     Inventory = GetComponent <Inventory.Inventory>();
 }