RiftMayhem/Assets/Scripts/Interactables/FishingSpotInteractable.cs
Pedro Gomes d75d51a9c4 Gameplay update
- Added multiple input modes:
   - Point and click (as before)
   - WASD + mouse aiming (fully supported) (need QoL for interactables)
   - Gamepad controls (partial support)

- Sprite indexer to avoid gamebreaking issues when serializing sprites
- Movement speed penalty on casting abilities instead of fully stopping agent
2025-01-17 20:16:02 +00:00

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, bool gamepadFocus = false)
{
base.OnFocused(playerTransform, playerController, gamepadFocus);
}
public override void OnDeFocus()
{
base.OnDeFocus();
}
}