- Refactor items from predefined scriptables only, to template based into item instances - Added equipped item tooltip to facilitate comparing items - Added modular craftable items
63 lines
1.4 KiB
C#
63 lines
1.4 KiB
C#
using Kryz.CharacterStats.Examples;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FishingSpotInteractable : Interactable
|
|
{
|
|
[SerializeField] private List<WeightedDrop> dropItems = new List<WeightedDrop>();
|
|
|
|
public bool interacted = false;
|
|
|
|
protected Item drop;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
}
|
|
|
|
public override void Interact(bool melee)
|
|
{
|
|
if (interacted) return;
|
|
|
|
interacted = true;
|
|
|
|
base.Interact(melee);
|
|
|
|
playerController.StartFishing();
|
|
|
|
StartCoroutine(FindFish());
|
|
}
|
|
|
|
IEnumerator FindFish()
|
|
{
|
|
yield return new WaitForSeconds(Random.Range(GameConstants.GameBalancing.MinimumFindFishWaitTime, GameConstants.GameBalancing.MaximumFindFishWaitTime));
|
|
|
|
playerController.GetComponentInChildren<CharacterAnimatorController>().OnPickup();
|
|
}
|
|
|
|
public void OnFishingEnded()
|
|
{
|
|
drop = WeightedDrop.GetRandomDrop(dropItems);
|
|
|
|
if(drop != null)
|
|
{
|
|
Inventory.Instance.AddItem(Item.ConvertTemplateIntoInstance(drop));
|
|
}
|
|
|
|
Destroy(this.gameObject);
|
|
}
|
|
|
|
public override void OnFocused(Transform playerTransform, PlayerController playerController)
|
|
{
|
|
base.OnFocused(playerTransform, playerController);
|
|
}
|
|
|
|
public override void OnDeFocus()
|
|
{
|
|
base.OnDeFocus();
|
|
}
|
|
|
|
|
|
}
|