MessageView.cs no animation
This commit is contained in:
parent
6d8233f33f
commit
6f8f58566c
3 changed files with 27 additions and 17 deletions
|
|
@ -1561,7 +1561,7 @@ MonoBehaviour:
|
||||||
m_OnCullStateChanged:
|
m_OnCullStateChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_Sprite: {fileID: 21300000, guid: 2a61ecc3d143def478dfed9f6d6ca3fd, type: 3}
|
m_Sprite: {fileID: 21300000, guid: 349d3f5d7a4156146b8e923d5c06314d, type: 3}
|
||||||
m_Type: 1
|
m_Type: 1
|
||||||
m_PreserveAspect: 0
|
m_PreserveAspect: 0
|
||||||
m_FillCenter: 1
|
m_FillCenter: 1
|
||||||
|
|
@ -2028,7 +2028,7 @@ MonoBehaviour:
|
||||||
m_HandleRect: {fileID: 2006577138}
|
m_HandleRect: {fileID: 2006577138}
|
||||||
m_Direction: 2
|
m_Direction: 2
|
||||||
m_Value: 1
|
m_Value: 1
|
||||||
m_Size: 0.5386614
|
m_Size: 0.5386615
|
||||||
m_NumberOfSteps: 0
|
m_NumberOfSteps: 0
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|
@ -2391,8 +2391,8 @@ RectTransform:
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 1, y: 1}
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
m_AnchoredPosition: {x: -811, y: 348.5}
|
m_AnchoredPosition: {x: -811, y: 290}
|
||||||
m_SizeDelta: {x: -1222, y: -697}
|
m_SizeDelta: {x: -1222, y: -580}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &615358672
|
--- !u!114 &615358672
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
|
@ -8187,7 +8187,7 @@ MonoBehaviour:
|
||||||
m_faceColor:
|
m_faceColor:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4294967295
|
rgba: 4294967295
|
||||||
m_fontSize: 72
|
m_fontSize: 29.25
|
||||||
m_fontSizeBase: 20
|
m_fontSizeBase: 20
|
||||||
m_fontWeight: 400
|
m_fontWeight: 400
|
||||||
m_enableAutoSizing: 1
|
m_enableAutoSizing: 1
|
||||||
|
|
@ -8839,7 +8839,7 @@ MonoBehaviour:
|
||||||
m_faceColor:
|
m_faceColor:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4294967295
|
rgba: 4294967295
|
||||||
m_fontSize: 72
|
m_fontSize: 29.25
|
||||||
m_fontSizeBase: 20
|
m_fontSizeBase: 20
|
||||||
m_fontWeight: 400
|
m_fontWeight: 400
|
||||||
m_enableAutoSizing: 1
|
m_enableAutoSizing: 1
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,13 @@ public class FishingController : MonoBehaviour {
|
||||||
private Vector2 _ampsXY;
|
private Vector2 _ampsXY;
|
||||||
private Inventory _iv;
|
private Inventory _iv;
|
||||||
private ItemContainer _ic;
|
private ItemContainer _ic;
|
||||||
|
private MessageView _messageView;
|
||||||
|
|
||||||
public bool Fishing => _fishing;
|
public bool Fishing => _fishing;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start() {
|
void Start() {
|
||||||
|
_messageView = MessageView.instance;
|
||||||
ResetFishing();
|
ResetFishing();
|
||||||
_ampsXY = new Vector2(10, 10);
|
_ampsXY = new Vector2(10, 10);
|
||||||
_iv = Inventory.instance;
|
_iv = Inventory.instance;
|
||||||
|
|
@ -59,7 +61,6 @@ public class FishingController : MonoBehaviour {
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update() {
|
void Update() {
|
||||||
if (_fishing) { //Fishing
|
if (_fishing) { //Fishing
|
||||||
|
|
||||||
if (!Catchable) {
|
if (!Catchable) {
|
||||||
// Fish not spawned yet
|
// Fish not spawned yet
|
||||||
fishCooldown -= Time.deltaTime;
|
fishCooldown -= Time.deltaTime;
|
||||||
|
|
@ -88,7 +89,7 @@ public class FishingController : MonoBehaviour {
|
||||||
|
|
||||||
public void StartFishing() {
|
public void StartFishing() {
|
||||||
if (!_iv.items.ContainsKey(_ic.GetItemByName("Bait"))) {
|
if (!_iv.items.ContainsKey(_ic.GetItemByName("Bait"))) {
|
||||||
Debug.Log("No bait!");
|
_messageView.sendMessage("No bait!", 1.0f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Vector3 pos = Input.mousePosition;
|
Vector3 pos = Input.mousePosition;
|
||||||
|
|
@ -107,21 +108,19 @@ public class FishingController : MonoBehaviour {
|
||||||
}
|
}
|
||||||
_fishing = true;
|
_fishing = true;
|
||||||
_iv.RemoveItem(_ic.GetItemByName("Bait"), 1);
|
_iv.RemoveItem(_ic.GetItemByName("Bait"), 1);
|
||||||
|
_messageView.sendMessage("Fishing started", 1.0f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TryCatch() {
|
public void TryCatch() {
|
||||||
if (_fishing && Catchable) {
|
if (_fishing && Catchable) {
|
||||||
Debug.Log("Tried to catch!");
|
|
||||||
if (_fishingTime <= MaxTime) {
|
if (_fishingTime <= MaxTime) {
|
||||||
Debug.Log("Caught!");
|
_messageView.sendMessage("Caught!", 1.5f);
|
||||||
_iv.AddItem(_ic.GetItemByName("Fish"), Math.Max((int)(1 / (_fishingTime / 2)), 1));
|
_iv.AddItem(_ic.GetItemByName("Fish"), Math.Max((int)(1 / (_fishingTime / 2)), 1));
|
||||||
ResetFishing();
|
|
||||||
} else {
|
} else {
|
||||||
Debug.Log("Failed to catch!");
|
_messageView.sendMessage("Failed to catch the fish! You were too slow!", 1.5f);
|
||||||
_fishingTime = 0f;
|
|
||||||
exMark.SetActive(false);
|
|
||||||
fishCooldown = Random.Range(MinFishCooldown + 2, MaxFishCooldown);
|
|
||||||
}
|
}
|
||||||
|
ResetFishing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,18 @@ public class MessageView : MonoBehaviour
|
||||||
public GameObject messageView;
|
public GameObject messageView;
|
||||||
public TextMeshProUGUI message;
|
public TextMeshProUGUI message;
|
||||||
|
|
||||||
public void sendMessage(String msg, double duration) {
|
private void Start() {
|
||||||
|
messageView.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(String msg, float duration) {
|
||||||
|
message.text = msg;
|
||||||
|
StartCoroutine(showForSeconds(duration));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator showForSeconds(float duration) {
|
||||||
|
messageView.SetActive(true);
|
||||||
|
yield return new WaitForSeconds(duration);
|
||||||
|
messageView.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue