public static void LeftClickUseEmpty(ItemParams args) { TilemapManager.Instance.DamageTile(TileLayer.Terrain, TilemapManager.Instance.TerrainTilemap.WorldToCell( args.TargetPosition), args.Damage, args.HitDirection); }
public override ItemParams Initialise(ItemParams args) { if (args.CurrentDurability <= 0) { args.CurrentDurability = Durability; } return(args); }
public void Initialise() { ItemParams args = new ItemParams(this); args = Item.Initialise(args); StackSize = args.StackSize; CurrentDurability = args.CurrentDurability; IntStore = args.IntStore; }
/// <summary> /// Generally treated as swinging the item at the target position /// </summary> /// <param name="args">Contains various input arguments based on target object</param> public virtual ItemParams LeftClickUse(ItemParams args) { TilemapManager.Instance.DamageTile(TileLayer.Terrain, TilemapManager.Instance.TerrainTilemap.WorldToCell( args.TargetPosition), args.Damage, args.HitDirection); return(args); }
public void UseSelectedItem(ItemParams args) { if (ItemList[SelectedSlot] != null && ItemList[SelectedSlot].UseItem(args)) { ItemList[SelectedSlot] = null; InventorySlotUpdated.Invoke(SelectedSlot); } else { if (args.ClickType == ClickType.Left) { Item.LeftClickUseEmpty(args); } } }
public override ItemParams RightClickUse(ItemParams args) { Vector2 position = args.TargetType == TargetType.Tile ? args.AdjacentPosition : args.TargetPosition; if (TilemapManager.Instance.TerrainTilemap.WorldToCell(position) != TilemapManager.Instance.TerrainTilemap.WorldToCell(args.OriginPosition)) { TilemapManager.Instance.TerrainTilemap.PlaceTile( TilemapManager.Instance.TerrainTilemap.WorldToCell(position), this); --args.StackSize; } return(args); }
public override ItemParams LeftClickUse(ItemParams args) { // Calc Damage amount args.Damage = BaseDamage; if (args.TileClass != TileClass.None && args.TileClass == Class) { args.Damage = ClassDamage; } // Apply Damage base.LeftClickUse(args); // Durability args.CurrentDurability -= 1; if (args.CurrentDurability <= 0) { --args.StackSize; } return(args); }
public bool UseItem(ItemParams args) { args.IntStore = IntStore; args.StackSize = StackSize; args.CurrentDurability = CurrentDurability; switch (args.ClickType) { default: args = Item.LeftClickUse(args); break; case ClickType.Right: args = Item.RightClickUse(args); break; } IntStore = args.IntStore; StackSize = args.StackSize; CurrentDurability = args.CurrentDurability; return(StackSize <= 0); }
private void Update() { switch (State) { case VerticalState.Grounded: if (Input.GetKey(KeyCode.Space)) { _targetJumpHeight = Center.y + Extents.y + (PlayerVars.JumpHeightBase * PlayerVars.JumpHeightModifier[PlayerVars.JumpHeightCurModifier]) + 0.2f; State = VerticalState.Jumping; } break; case VerticalState.Jumping: break; case VerticalState.Falling: break; } _moveInput = Input.GetAxisRaw("Horizontal"); if (_moveInput < 0) { BodySprite.transform.localScale = new Vector3(-1, 1, 1); } else if (_moveInput > 0) { BodySprite.transform.localScale = new Vector3(1, 1, 1); } // Get the current target ItemParams item = GetTarget(); // Left Click if (Input.GetMouseButton(0)) { if (_canSwing) { item.ClickType = ClickType.Left; PlayerInventory.UseSelectedItem(item); StartCoroutine(SwingTimer()); } } // Right Click if (Input.GetMouseButtonDown(1)) { item.ClickType = ClickType.Right; PlayerInventory.UseSelectedItem(item); } // UI Slot selection // TODO: Should this be in a separate script? if (Input.GetKeyDown(KeyCode.Alpha1)) { PlayerInventory.ChangeSelectedSlot(0); } if (Input.GetKeyDown(KeyCode.Alpha2)) { PlayerInventory.ChangeSelectedSlot(1); } float scroll = Input.GetAxisRaw("Mouse ScrollWheel"); if (scroll != 0) { if (scroll > 0) { PlayerInventory.ChangeSelectedSlot(PlayerInventory.SelectedSlot - 1); } else { PlayerInventory.ChangeSelectedSlot(PlayerInventory.SelectedSlot + 1); } } }
/// <summary> /// Generally treated as placing the item in some way /// </summary> /// <param name="args">Contains various input arguments based on target object</param> public virtual ItemParams RightClickUse(ItemParams args) { args.ResolutionType = ResolutionType.None; return(args); }
/// <summary> /// Allows more advanced items to set up any data store information they need /// </summary> /// <param name="args"></param> /// <returns></returns> public virtual ItemParams Initialise(ItemParams args) { return(args); }