Send berry collect event... on berry collect
This commit is contained in:
3 files changed
+26
-7
No files matched your search
@@ -330,7 +330,7 @@ public class MultiplayerGamePlayer : MonoBehaviour {
|
|||||||
slownessLeft = 0f;
|
slownessLeft = 0f;
|
||||||
UpdateStats(0, 1);
|
UpdateStats(0, 1);
|
||||||
|
|
||||||
foreach (GameObject berry in berries.Values) RemoveBerry(berry);
|
foreach (GameObject berry in berries.Values.ToList()) RemoveBerry(berry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateStats(BigInteger scoreAddAmount, BigInteger attemptAddAmount) {
|
void UpdateStats(BigInteger scoreAddAmount, BigInteger attemptAddAmount) {
|
||||||
@@ -396,7 +396,7 @@ public class MultiplayerGamePlayer : MonoBehaviour {
|
|||||||
|
|
||||||
void DoNormalBerry(GameObject berry) {
|
void DoNormalBerry(GameObject berry) {
|
||||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Eat"), Camera.main.transform.position, 1.2f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||||
RemoveBerry(berry);
|
RemoveBerry(berry, true);
|
||||||
UpdateStats(1, 0);
|
UpdateStats(1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +408,7 @@ public class MultiplayerGamePlayer : MonoBehaviour {
|
|||||||
|
|
||||||
void DoSlowBerry(GameObject berry) {
|
void DoSlowBerry(GameObject berry) {
|
||||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Downgrade"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||||
RemoveBerry(berry);
|
RemoveBerry(berry, true);
|
||||||
boostLeft = 0f;
|
boostLeft = 0f;
|
||||||
slownessLeft = 10f;
|
slownessLeft = 10f;
|
||||||
if (score > 0) {
|
if (score > 0) {
|
||||||
@@ -418,7 +418,7 @@ public class MultiplayerGamePlayer : MonoBehaviour {
|
|||||||
|
|
||||||
void DoUltraBerry(GameObject berry) {
|
void DoUltraBerry(GameObject berry) {
|
||||||
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
AudioSource.PlayClipAtPoint(Resources.Load<AudioClip>("Sounds/Powerup"), Camera.main.transform.position, 0.35f * BazookaManager.Instance.GetSettingSFXVolume());
|
||||||
RemoveBerry(berry);
|
RemoveBerry(berry, true);
|
||||||
if (slownessLeft > 0f) {
|
if (slownessLeft > 0f) {
|
||||||
slownessLeft = 0f;
|
slownessLeft = 0f;
|
||||||
UpdateStats(1, 0);
|
UpdateStats(1, 0);
|
||||||
@@ -447,7 +447,7 @@ public class MultiplayerGamePlayer : MonoBehaviour {
|
|||||||
MultiplayerLeaveMessage msg = new();
|
MultiplayerLeaveMessage msg = new();
|
||||||
WebsocketHandler.Instance._Connection.AddOutgoingMessage(JsonUtility.ToJson(msg));
|
WebsocketHandler.Instance._Connection.AddOutgoingMessage(JsonUtility.ToJson(msg));
|
||||||
}
|
}
|
||||||
await SceneManager.LoadSceneAsync("PlayMenu");
|
await SceneManager.LoadSceneAsync("MainMenu");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessSpawns() {
|
void ProcessSpawns() {
|
||||||
@@ -497,10 +497,19 @@ public class MultiplayerGamePlayer : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveBerry(GameObject berry) {
|
void RemoveBerry(GameObject berry, bool letServerKnow = false) {
|
||||||
|
string tag = berry.tag;
|
||||||
Destroy(berry);
|
Destroy(berry);
|
||||||
var key = berries.FirstOrDefault(kvp => kvp.Value == berry).Key;
|
var key = berries.FirstOrDefault(kvp => kvp.Value == berry).Key;
|
||||||
if (key != null) berries.Remove(key);
|
if (key != null) {
|
||||||
|
berries.Remove(key);
|
||||||
|
if (tag != null && letServerKnow) {
|
||||||
|
MultiplayerBerryCollectMessage msg = new() {
|
||||||
|
id = key.ID
|
||||||
|
};
|
||||||
|
WebsocketHandler.Instance._Connection.AddOutgoingMessage(JsonUtility.ToJson(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreatePlayer(MultiplayerPlayerFromResponse player) {
|
void CreatePlayer(MultiplayerPlayerFromResponse player) {
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class MultiplayerBerryCollectMessage {
|
||||||
|
public string type = "multiplayer_berry_collect";
|
||||||
|
public string id;
|
||||||
|
public long timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 51261112c59ed4588bbfca331b24a092
|
||||||
Reference in new issue
Block a user