Skin network sync, new server build

This commit is contained in:
Sewmina 2024-09-26 23:46:18 +05:30
parent c29b03d428
commit e711e19fe1
8 changed files with 102 additions and 98 deletions

View File

@ -56,5 +56,5 @@
"temp/": true,
"Temp/": true
},
"dotnet.defaultSolution": "2DMMOMirror.sln"
"dotnet.defaultSolution": "Archive.sln"
}

View File

@ -9095,7 +9095,6 @@ MonoBehaviour:
syncMode: 0
syncInterval: 0
statManager: {fileID: 0}
charSelectionManager: {fileID: 0}
health: 100
character: {fileID: 6938941000042972233}
characterMan: {fileID: 7345234694237798538}
@ -9105,6 +9104,7 @@ MonoBehaviour:
XP: 0
playerName:
playerCoin: 0
myCharJson:
txtEnemyKillCount: {fileID: 7507179777535427855}
txtPlayerName: {fileID: 1147545454032894846}
questText: {fileID: 8854752643845377920}

View File

@ -38,6 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -327930,15 +327931,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0.3, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -328022,15 +328021,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -460414,15 +460411,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: -7909654892493620595, guid: cd20e8790f3e4884ca3c74989aa84a83, type: 3}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -591672,15 +591667,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 2
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -642714,15 +642707,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 4.34, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -643928,15 +643919,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -659574,15 +659563,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 2
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -659663,15 +659650,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -695047,15 +695032,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 0
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 0001030405
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -695121,15 +695104,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 0
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 0001030405
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -710425,15 +710406,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 2
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -720250,15 +720229,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 2
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -720343,15 +720320,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 2
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -726743,15 +726718,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -727967,15 +727940,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 2
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -772571,15 +772542,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: -7909654892493620595, guid: cd20e8790f3e4884ca3c74989aa84a83, type: 3}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}
@ -774001,15 +773970,13 @@ ParticleSystemRenderer:
m_RenderAlignment: 0
m_Pivot: {x: 0, y: 0.3, z: 0}
m_Flip: {x: 0, y: 0, z: 0}
m_UseCustomVertexStreams: 0
m_EnableGPUInstancing: 1
m_ApplyActiveColorSpace: 1
m_AllowRoll: 1
m_FreeformStretching: 0
m_RotateWithStretchDirection: 1
m_UseCustomVertexStreams: 0
m_VertexStreams: 00010304
m_UseCustomTrailVertexStreams: 0
m_TrailVertexStreams: 00010304
m_Mesh: {fileID: 0}
m_Mesh1: {fileID: 0}
m_Mesh2: {fileID: 0}

View File

@ -18,6 +18,7 @@ public class ChangeCharacterOnSelection : MonoBehaviour
}
void RefreshCharacter(){
if(CharacterSelection.selectedCharJson == null){return;}
if(CharacterSelection.selectedCharJson.Length <= 0){return;}
character.FromJson(CharacterSelection.selectedCharJson, true);
}

View File

@ -1,16 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Firebase.Extensions;
using Firebase.Firestore;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class CharacterSelection : MonoBehaviour
{
public static string selectedCharJson;
public static string selectedCharJson = "";
public List<string> predefinedCharacterJsons;
public List<Button> predefinedCharacterButtons;
@ -19,30 +17,33 @@ public class CharacterSelection : MonoBehaviour
void Start()
{
for(int i=0; i < predefinedCharacterButtons.Count; i++){
for (int i = 0; i < predefinedCharacterButtons.Count; i++)
{
int tempI = i;
predefinedCharacterButtons[i].onClick.AddListener(() => { OnPredefinedCharButtonPress(tempI); });
}
LoadCharacterSkinCloud();
}
public void LoadCharacterFromString(string characterData){
public void LoadCharacterFromString(string characterData)
{
selectedCharJson = characterData;
OnCharacterChanged.Invoke();
}
void OnPredefinedCharButtonPress(int i){
void OnPredefinedCharButtonPress(int i)
{
selectedCharJson = predefinedCharacterJsons[i];
OnCharacterChanged.Invoke();
SaveCharacterSkinCloud();
}
public static void SaveCharacterSkinCloud(){
public static void SaveCharacterSkinCloud()
{
#if UNITY_EDITOR
PlayerPrefs.SetString("skinData", selectedCharJson);
PlayerPrefs.Save();
#endif
#else
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
Dictionary<string,object> skindataDictionary = new Dictionary<string, object>();
@ -58,16 +59,18 @@ public class CharacterSelection : MonoBehaviour
}
});
#endif
}
void LoadCharacterSkinCloud(){
void LoadCharacterSkinCloud()
{
#if UNITY_EDITOR
if(PlayerPrefs.HasKey("skinData")){
if (PlayerPrefs.HasKey("skinData"))
{
LoadCharacterFromString(PlayerPrefs.GetString("skinData"));
}
#endif
#else
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
DocumentReference docRef = db.Collection("SkinData").Document(gplayAuth.userID);
@ -85,5 +88,7 @@ public class CharacterSelection : MonoBehaviour
}
});
#endif
}
}

View File

@ -14,14 +14,13 @@ using UnityEngine.SocialPlatforms;
using Firebase.Auth;
using UnityEngine.UI;
using Newtonsoft.Json;
using Unity.Properties;
public class playerNetwork : NetworkBehaviour
{
public const float ATTACK_COOLDOWN = 0.6f;
[HideInInspector]
public StatManager statManager;
public CharacterSelection charSelectionManager;
//public const int XPFORLEVEL = 10;
[SyncVar(hook =nameof(OnHealthChanged))] public int health = 100;
public Character4D character;
@ -44,6 +43,7 @@ public class playerNetwork : NetworkBehaviour
[SyncVar(hook = nameof(OnXpChanged))]
public int XP;
public int lvl2 { get{
return GetLevelForKills2(enemyKillCount);
}}
@ -124,6 +124,9 @@ public class playerNetwork : NetworkBehaviour
[SyncVar]
public int playerCoin;
[SyncVar]
public string myCharJson;
public TMP_Text txtEnemyKillCount;
public TMP_Text txtPlayerName;
public TMP_Text questText;
@ -200,8 +203,10 @@ public class playerNetwork : NetworkBehaviour
// }
if(!isLocalPlayer){
canvas.SetActive(false);
if(!isServer){
CmdRequestCharJson();
}
}else{
localPlayerTransform = transform;
@ -216,12 +221,21 @@ public class playerNetwork : NetworkBehaviour
if(isServer){
playerName = gplayAuth.userNameCloud;
myCharJson = CharacterSelection.selectedCharJson;
RpcBroadcastCharJson(CharacterSelection.selectedCharJson);
}
else{
CmdSetName(gplayAuth.userNameCloud);
CmdSetCharJson(CharacterSelection.selectedCharJson);
}
}
}
void LoadCharFromJson(string json){
if(json.Length <=0){return;}
character.FromJson(json,true);
}
public void SavePlayerData(){
@ -314,10 +328,28 @@ public class playerNetwork : NetworkBehaviour
}
});
}
[Command]
void CmdSetName(string nameValue){
playerName = nameValue;
}
[Command(requiresAuthority =false)]
void CmdRequestCharJson(){
RpcBroadcastCharJson(myCharJson);
}
[Command]
void CmdSetCharJson(string newValue){
myCharJson = newValue;
RpcBroadcastCharJson(newValue);
LoadCharFromJson(newValue);
}
[ClientRpc]
void RpcBroadcastCharJson(string newValue){
LoadCharFromJson(newValue);
}
void OnDirectionChanged(Vector2 oldVal, Vector2 newVal){
character.SetDirection(newVal);
}

View File

@ -8,11 +8,11 @@
"hash": "f8c8347af3a144069dffd6120f1c4142f8120891"
},
"com.unity.2d.animation": {
"version": "9.1.1",
"version": "9.0.3",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.2d.common": "8.0.2",
"com.unity.2d.common": "8.0.1",
"com.unity.2d.sprite": "1.0.0",
"com.unity.collections": "1.1.0",
"com.unity.modules.animation": "1.0.0",
@ -21,7 +21,7 @@
"url": "https://packages.unity.com"
},
"com.unity.2d.aseprite": {
"version": "1.1.4",
"version": "1.0.0",
"depth": 1,
"source": "registry",
"dependencies": {
@ -33,7 +33,7 @@
"url": "https://packages.unity.com"
},
"com.unity.2d.common": {
"version": "8.0.2",
"version": "8.0.1",
"depth": 2,
"source": "registry",
"dependencies": {
@ -53,13 +53,13 @@
"url": "https://packages.unity.com"
},
"com.unity.2d.psdimporter": {
"version": "8.0.5",
"version": "8.0.2",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.2d.common": "8.0.2",
"com.unity.2d.common": "8.0.1",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.animation": "9.1.1"
"com.unity.2d.animation": "9.0.1"
},
"url": "https://packages.unity.com"
},
@ -70,11 +70,11 @@
"dependencies": {}
},
"com.unity.2d.spriteshape": {
"version": "9.0.3",
"version": "9.0.2",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.2d.common": "8.0.2",
"com.unity.2d.common": "8.0.1",
"com.unity.mathematics": "1.1.0",
"com.unity.modules.physics2d": "1.0.0"
},
@ -90,7 +90,7 @@
}
},
"com.unity.2d.tilemap.extras": {
"version": "3.1.2",
"version": "3.1.1",
"depth": 1,
"source": "registry",
"dependencies": {
@ -102,12 +102,11 @@
"url": "https://packages.unity.com"
},
"com.unity.burst": {
"version": "1.8.15",
"version": "1.8.7",
"depth": 3,
"source": "registry",
"dependencies": {
"com.unity.mathematics": "1.2.1",
"com.unity.modules.jsonserialize": "1.0.0"
"com.unity.mathematics": "1.2.1"
},
"url": "https://packages.unity.com"
},
@ -140,14 +139,14 @@
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.2d.animation": "9.1.1",
"com.unity.2d.animation": "9.0.3",
"com.unity.2d.pixel-perfect": "5.0.3",
"com.unity.2d.psdimporter": "8.0.5",
"com.unity.2d.psdimporter": "8.0.2",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.spriteshape": "9.0.3",
"com.unity.2d.spriteshape": "9.0.2",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.2d.tilemap.extras": "3.1.2",
"com.unity.2d.aseprite": "1.1.4"
"com.unity.2d.tilemap.extras": "3.1.1",
"com.unity.2d.aseprite": "1.0.0"
}
},
"com.unity.ide.rider": {

View File

@ -1,2 +1,2 @@
m_EditorVersion: 2022.3.33f1
m_EditorVersionWithRevision: 2022.3.33f1 (b2c853adf198)
m_EditorVersion: 2022.3.7f1
m_EditorVersionWithRevision: 2022.3.7f1 (b16b3b16c7a0)