Meta and stuff
This commit is contained in:
parent
f8da73695c
commit
9c31bcc303
8 changed files with 197 additions and 3 deletions
8
Assets/Farming Asset Pack/Split Assets.meta
Normal file
8
Assets/Farming Asset Pack/Split Assets.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f8e433f0b06051243aaf8575a862a7e4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
19
Assets/Resources/Items/Fish.asset
Normal file
19
Assets/Resources/Items/Fish.asset
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5f096d187f76a734fac022700054dfec, type: 3}
|
||||||
|
m_Name: Fish
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
displayName: Fish
|
||||||
|
description: Used to slap people.
|
||||||
|
selectedSprite: {fileID: 21300000, guid: 8c01c1a230575ac4bb0aee5ba1c7757a, type: 3}
|
||||||
|
defaultSprite: {fileID: 21300000, guid: d1b54b7f17e2d4d4e82d50d710d4482c, type: 3}
|
||||||
|
cost: 150
|
||||||
8
Assets/Resources/Items/Fish.asset.meta
Normal file
8
Assets/Resources/Items/Fish.asset.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7fc4aaa640c1c1e49a0c0a9241fbcf07
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
20
Assets/Resources/Items/Usable/Shovel.asset
Normal file
20
Assets/Resources/Items/Usable/Shovel.asset
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 761f645f009328845bc7851753024e92, type: 3}
|
||||||
|
m_Name: Shovel
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
displayName: Shovel
|
||||||
|
description: Used to dig ground.
|
||||||
|
id: 6
|
||||||
|
selectedSprite: {fileID: 21300000, guid: 58952d7ae1da0f0468af9c9d916af2fc, type: 3}
|
||||||
|
defaultSprite: {fileID: 21300000, guid: 1ea3a182dfc173440993d81065fdbdf0, type: 3}
|
||||||
|
cost: 200
|
||||||
8
Assets/Resources/Items/Usable/Shovel.asset.meta
Normal file
8
Assets/Resources/Items/Usable/Shovel.asset.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6bac44b5c4527b641a3ae772d217ec43
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
114
Assets/Scripts/FishingController.cs
Normal file
114
Assets/Scripts/FishingController.cs
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.Common;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Threading;
|
||||||
|
using UnityEngine;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
|
public class FishingController : MonoBehaviour {
|
||||||
|
#region Singleton
|
||||||
|
|
||||||
|
public static FishingController instance;
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
if (instance != null) {
|
||||||
|
Debug.LogWarning("More than one instance of FishingController found");
|
||||||
|
}
|
||||||
|
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public GameObject _exMark;
|
||||||
|
|
||||||
|
private double _fishingTime;
|
||||||
|
private double _fishCooldown;
|
||||||
|
private readonly float _minFishCooldown = 1.5f;
|
||||||
|
private readonly float _maxFishCooldown = 7f;
|
||||||
|
private readonly double _maxTime = 2f;
|
||||||
|
private bool _fishing;
|
||||||
|
private bool _catchable;
|
||||||
|
private bool _caught;
|
||||||
|
private Vector2 _ampsXY;
|
||||||
|
|
||||||
|
public bool Fishing => _fishing;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start() {
|
||||||
|
ResetFishing();
|
||||||
|
_ampsXY = new Vector2(10, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update() {
|
||||||
|
if (_fishing) { //Fishing
|
||||||
|
if (!_catchable) { // Fish not spawned yet
|
||||||
|
_fishCooldown -= Time.deltaTime;
|
||||||
|
if (_fishCooldown <= 0) { //fish will get spawned
|
||||||
|
_catchable = true;
|
||||||
|
if (!_exMark.activeSelf) {
|
||||||
|
_exMark.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_fishingTime += Time.deltaTime;
|
||||||
|
//NotifyShake();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NotifyShake() {
|
||||||
|
_exMark.transform.position =
|
||||||
|
new Vector3(_exMark.transform.position.x * _ampsXY.x * Time.deltaTime,
|
||||||
|
_exMark.transform.position.y * _ampsXY.y * Time.deltaTime,
|
||||||
|
transform.position.z);
|
||||||
|
_ampsXY.x *= -1;
|
||||||
|
_ampsXY.y *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetFishing() {
|
||||||
|
_fishing = false;
|
||||||
|
_catchable = false;
|
||||||
|
_fishingTime = 0f;
|
||||||
|
_fishCooldown = Random.Range(_minFishCooldown, _maxFishCooldown);
|
||||||
|
_exMark.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartFishing() {
|
||||||
|
Vector3 pos = Input.mousePosition;
|
||||||
|
|
||||||
|
if (Camera.main != null) {
|
||||||
|
float newPosX = pos.x;
|
||||||
|
float newPosY;
|
||||||
|
|
||||||
|
if (pos.y - 50 - ((RectTransform)_exMark.transform).rect.height >= 0) { //check if bottom of panel is in screen
|
||||||
|
newPosY = pos.y - ((RectTransform)_exMark.transform).rect.height;
|
||||||
|
} else {
|
||||||
|
newPosY = pos.y + ((RectTransform)_exMark.transform).rect.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
_exMark.transform.position = new Vector3(newPosX, newPosY);
|
||||||
|
}
|
||||||
|
_fishing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TryCatch() {
|
||||||
|
if (_fishing && _catchable) {
|
||||||
|
Debug.Log("Tried to catch!");
|
||||||
|
if (_fishingTime <= _maxTime) {
|
||||||
|
Debug.Log("Caught!");
|
||||||
|
Inventory.instance.AddItem(ItemContainer.Instance.GetItemByName("Fish"), (int)(3 / _fishingTime));
|
||||||
|
ResetFishing();
|
||||||
|
} else {
|
||||||
|
Debug.Log("Failed to catch!");
|
||||||
|
_catchable = false;
|
||||||
|
_fishingTime = 0f;
|
||||||
|
_exMark.SetActive(false);
|
||||||
|
_fishCooldown = Random.Range(_minFishCooldown+2, _maxFishCooldown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/FishingController.cs.meta
Normal file
11
Assets/Scripts/FishingController.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 00d85fb65e728cd429cb33d865a5d31a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -26,8 +26,10 @@ public class ItemContainer : MonoBehaviour {
|
||||||
string[] files =
|
string[] files =
|
||||||
Directory.GetFiles("Assets\\Resources\\Items", "*.asset", SearchOption.AllDirectories);
|
Directory.GetFiles("Assets\\Resources\\Items", "*.asset", SearchOption.AllDirectories);
|
||||||
foreach (string file in files) {
|
foreach (string file in files) {
|
||||||
String path = file.Replace("Assets\\Resources\\", "").Replace(".asset", "");
|
String path = StripPath(file);
|
||||||
_allItems.Add(Resources.Load<Item>(path));
|
Item currItem = Resources.Load<Item>(path);
|
||||||
|
currItem.SetID(_allItems.Count);
|
||||||
|
_allItems.Add(currItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +43,11 @@ public class ItemContainer : MonoBehaviour {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String StripPath(String path) {
|
||||||
|
return path.Replace("Assets\\Resources\\", "").Replace(".asset", "");
|
||||||
|
}
|
||||||
|
|
||||||
public int GetItemIdByName(String name) {
|
public int GetItemIdByName(String name) {
|
||||||
return GetItemByName(name).id;
|
return GetItemByName(name).ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue