public override void DoAction(PlayerCharacter character, ItemSlot slot)
        {
            DigSpot spot  = DigSpot.GetNearest(character.transform.position, dig_range);
            Plant   plant = Plant.GetNearest(character.transform.position, dig_range);

            Vector3 pos = plant != null ? plant.transform.position : character.transform.position;

            if (spot != null)
            {
                pos = spot.transform.position;
            }

            string animation = character.Animation ? character.Animation.dig_anim : "";

            character.TriggerAnim(animation, pos);
            character.TriggerProgressAction(1.5f, () =>
            {
                if (spot != null)
                {
                    spot.Dig();
                }
                else if (plant != null)
                {
                    plant.Kill();
                }

                InventoryItemData ivdata = character.EquipData.GetItem(slot.index);
                if (ivdata != null)
                {
                    ivdata.durability -= 1;
                }
            });
        }
Пример #2
0
        private IEnumerator DigRoutine()
        {
            yield return(new WaitForSeconds(1f));

            if (action_target != null)
            {
                DigSpot dig = action_target.GetComponent <DigSpot>();
                if (dig != null)
                {
                    dig.Dig();
                }
            }

            StopAction();
        }
        public override void DoAction(PlayerCharacter character, Selectable select)
        {
            DigSpot spot = select.GetComponent <DigSpot>();

            if (spot != null)
            {
                string animation = character.Animation ? character.Animation.dig_anim : "";
                character.TriggerAnim(animation, spot.transform.position);
                character.TriggerProgressAction(1.5f, () =>
                {
                    spot.Dig();

                    InventoryItemData ivdata = character.EquipData.GetFirstItemInGroup(required_item);
                    if (ivdata != null)
                    {
                        ivdata.durability -= 1;
                    }
                });
            }
        }